/******************************************************************************
 * @File name   :      ProxyJndiObjectFactoryBean.java
 *
 * @Author      :      Brenda Yin
 *
 * @Date        :      2012-6-15
 *
 * @Copyright Notice: 
 * Copyright (c) 2014 DMS, Inc. All  Rights Reserved.
 * This software is published under the terms of the DMS Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * 2012-6-15 下午09:06:11        Brenda Yin     1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.framework.proxy;


import java.lang.reflect.Proxy;

import javax.sql.DataSource;

import org.springframework.jndi.JndiObjectFactoryBean;

/**
 * try to fix Oracle mutex lock issue
 */
public class ProxyJndiObjectFactoryBean extends JndiObjectFactoryBean {
	/**
	 * @Date        :      2012-6-15
	 * @param datasource
	 */
	@Override
	public Object getObject() {
		DataSource ds=(DataSource)(super.getObject());
		//DataSource ds = (DataSource)datasource.getObject();
		ds = (DataSource) Proxy.newProxyInstance(ds.getClass()
				.getClassLoader(), new Class[] { DataSource.class },
				new ProxyDataSource(ds));
		return ds;
	}

}
